package org.jsbd.boss.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.*;

/**
 * 
 * TODO 请加入本类的说明
 * 
 * @author <a href="mailto:zhangbinghua@zhexinit.com" >zbh</a>
 * @version 1.0.0
 */
public class ADPoolExecutor {

	public static final Logger LOGGER = LoggerFactory.getLogger(ADPoolExecutor.class);
	private static Integer tasktimeout = 30 * 1000;
	private static BlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(200);

	private static ExecutorService executor = new ThreadPoolExecutor(200, 200, 1, TimeUnit.SECONDS, queue,
			new ThreadPoolExecutor.AbortPolicy());

	public static void getPoolExeFuture(FutureTask future) {
		try {
			final Future future1 =  executor.submit(future);
			 new Thread() {
					public void run() {
						try {
							future1.get();
						} catch (ExecutionException e1) {
							LOGGER.error("ADPoolExecutor ExecutionException");
						} catch (InterruptedException e2) {
							LOGGER.error("ADPoolExecutor InterruptedException");
						} 
					}
				}.start();
		} catch (Exception e) {
			LOGGER.error("InterruptedException: ADPoolExecutor  executor rejected");
		}
	}

}
